<?php
## include required files
/*******************************/
require_once '../../includefiles.php';
require_once '../../model/trade.php';
include_once("../../model/users.php");
require_once '../../model/state.php';
require_once '../../redirect.php';
require_once '../../model/nab.php';
require_once '../../model/paypal.php';
## Create Objects
/*******************************/
$objTrade = new Model_TRADE();
$userObj = new Model_Users();
$stateObj = new Model_State();
$nabObj = new Model_NAB();
$nab = $nabObj->getDetail();
$paypalObj = new Model_Paypal();
$paypal = $paypalObj->getDetail();
/*******************************/
$allsubcats = $objTrade->getAllSubcats();
$userId = $_SESSION['getbids_id'];
checkUserLogin();


if($_SESSION['user_type'] == '3')
{
	@header("location:".SITE_URL."/");
	exit;
}

if(!$_SESSION['cats']['list'] || !$_SESSION['cats']['subtotal'])
{
	@header("location:".SITE_URL."/myaccount/myservicelocation/");
	exit;
}

//calculate total
if($_SESSION['cats']['subtotal']==0)
{
	$objTrade->updateUserTrades($userId,$_SESSION['cats']['list']);
	unset($_SESSION['cats']);
	$_SESSION['msg'] = "<div class='success_msg'><span>Your trades has been updated</span></div>";
	@header("location:".SITE_URL."/myaccount/myservicelocation/");
	exit;	
}
//calculate tax
$subtotal = $_SESSION['cats']['subtotal'];
$tax = ($nab["tax"] * $subtotal)/100;
$total = $subtotal + $tax;
$_SESSION['cats']['tax'] = $tax;
$_SESSION['cats']['total'] = $total;

$smarty->assign('subtotal',number_format($subtotal,2));
$smarty->assign('tax',number_format($tax,2));
$smarty->assign('total',number_format($total,2));
$smarty->assign('subcats',$_SESSION['cats']['list']);


$smarty->assign('nab',$nab);
$smarty->assign('paypal',$nab);

$yr_arr = array();
for($i=date('Y');$i<=date('Y')+15;$i++)
{
	$yr_arr[] = $i;
}
$smarty->assign('yr_arr',$yr_arr);

$active = "myaccount";
$smarty->assign("active", $active);
$subactive ="myservicelocation";
$smarty->assign("subactive", $subactive);
$smarty->assign('mainmenu', '3');
$smarty->assign('serviceslist', '1');
$smarty->display(TEMPLATEDIR . '/modules/myaccount/paymentmethod.tpl');
?>